//
//  LGStatusModel.swift
//  LGWeibo
//
//  Created by 李更 on 8/13/16.
//  Copyright © 2016 itcast. All rights reserved.
//

import UIKit

class LGStatusModel: NSObject {
    
    // MARK: - 模型属性
    /// 创建时间
    var created_at: String?
    /// 微博ID
    var id: Int = 0
    /// 微博信息内容
    var text: String?
    /// 微博来源
    var source: String?
    //用户
    var user : LGUserModel?
    //转发微博
    var retweeted_status : LGStatusModel?
    //图片
    var pic_urls : [LGPictureInfo]?
    
    
  
     init(dict:[String: AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    override func setValue(value: AnyObject?, forKey key: String) {
        if key == "user" {
            guard let v = value as? [String : AnyObject] else{
                return
            }
            
            user = LGUserModel(dict: v)
        }else if key == "retweeted_status"{
            guard let v = value as? [String : AnyObject] else{
                return
            }
            
            retweeted_status = LGStatusModel(dict: v)
            
        }else if key == "pic_urls"{
            
            guard let v = value as? [[String : AnyObject]] else{
                return
            }
            
            //创建临时可变数组
            var tempArray : [LGPictureInfo] = [LGPictureInfo]()
            for dic in v {
                let pic = LGPictureInfo(dic: dic)
                tempArray.append(pic)
                
            }
            
            pic_urls = tempArray
            
            
        }else{
            super.setValue(value, forKey: key)
        }
    }
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
    

}
